package org.kl.wx.entity;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.kl.bf.entity.AuditableEntity;
import org.kl.bf.entity.Excel;
import org.kl.bf.utils.BasicConstants;

/**
 * 微信菜单
 */

@Entity
@Table(name = "wx_menu")
public class WxLocolMenu extends AuditableEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8230674162339796541L;

	@Excel(exportName = "所属公共账号", exportProperty = "appName")
	private App app;// 所属APP
	@Excel(exportName = "所属菜单", exportProperty = "menuName")
	private WxLocolMenu menu;// 所属菜单
	@Excel(exportName = "菜单名称")
	private String menuName;// 菜单名称
	@Excel(exportName = "菜单动作类型")
	private String menuType;// 菜单动作类型
	@Excel(exportName = "菜单Key值")
	private String menuKey;// 菜单Key值
	@Excel(exportName = "菜单URL")
	private String menuUrl;// 菜单URL
	@Excel(exportName = "媒体ID")
	private String mediaId;// 媒体ID
	private String stateName;
	private Integer oauthState = BasicConstants.NO_INT;
	private String menuParentId;

	public WxLocolMenu() {

	}

	public WxLocolMenu(String id) {
		this.id = id;
	}

	public String getMenuName() {
		return menuName;
	}

	public void setMenuName(String menuName) {
		this.menuName = menuName;
	}

	public String getMenuType() {
		return menuType;
	}

	public void setMenuType(String menuType) {
		this.menuType = menuType;
	}

	public String getMenuKey() {
		return menuKey;
	}

	public void setMenuKey(String menuKey) {
		this.menuKey = menuKey;
	}

	public String getMenuUrl() {
		return menuUrl;
	}

	public void setMenuUrl(String menuUrl) {
		this.menuUrl = menuUrl;
	}

	public String getMediaId() {
		return mediaId;
	}

	public void setMediaId(String mediaId) {
		this.mediaId = mediaId;
	}

	@ManyToOne
	@JoinColumn(name = "app_id")
	public App getApp() {
		return app;
	}

	public void setApp(App app) {
		this.app = app;
	}

	@ManyToOne
	@JoinColumn(name = "MENU_PARENT_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	public WxLocolMenu getMenu() {
		return menu;
	}

	public void setMenu(WxLocolMenu menu) {
		this.menu = menu;
	}

	@Transient
	public String getMenuParentId() {
		if (menu != null) {
			return menu.getId();
		}
		return menuParentId;
	}

	public void setMenuParentId(String menuParentId) {
		this.menuParentId = menuParentId;
	}

	public String getStateName() {
		return stateName;
	}

	public void setStateName(String stateName) {
		this.stateName = stateName;
	}

	public Integer getOauthState() {
		return oauthState;
	}

	public void setOauthState(Integer oauthState) {
		this.oauthState = oauthState;
	}

}
